package com.bjbn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjbn.entity.BmsDeviceValueLxHis;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Delete;

import java.util.List;

/**
 * 照度传感器历史数据Mapper接口
 */
@Mapper
public interface BmsDeviceValueLxHisMapper extends BaseMapper<BmsDeviceValueLxHis> {
    
    /**
     * 批量查询历史数据用于迁移
     * 
     * @param offset 偏移量
     * @param limit 限制数量
     * @return 历史数据列表
     */
    @Select("SELECT * FROM t_bms_device_value_lx_his ORDER BY id LIMIT #{limit} OFFSET #{offset}")
    List<BmsDeviceValueLxHis> selectBatchForMigration(@Param("offset") int offset, @Param("limit") int limit);
    
    /**
     * 删除指定日期之前的历史数据
     * 
     * @param beforeDate 删除此日期之前的数据
     * @return 删除的记录数
     */
    @Delete("DELETE FROM t_bms_device_value_lx_his WHERE create_time < #{beforeDate}")
    int deleteHistoryDataBeforeDate(@Param("beforeDate") String beforeDate);
} 